package team.bluepen.supermarket.data.entity;

import java.io.Serializable;

/**
 * @author RollW
 */
public class ProductStatePair implements Serializable {
    private final int activeCount;
    private final int inactiveCount;

    public ProductStatePair(int activeCount, int inactiveCount) {
        this.activeCount = activeCount;
        this.inactiveCount = inactiveCount;
    }

    public int getActiveCount() {
        return activeCount;
    }

    public int getInactiveCount() {
        return inactiveCount;
    }

    public static ProductStatePair add(ProductStatePair a, ProductStatePair b) {
        return new ProductStatePair(
                a.getActiveCount() + b.getActiveCount(),
                a.getInactiveCount() + b.getInactiveCount());
    }

    public static ProductStatePair add(ProductStatePair a, boolean state, int count) {
        return new ProductStatePair(
                a.getActiveCount() + (state ? count : 0),
                a.getInactiveCount() + (state ? 0 : count));
    }

    public static ProductStatePair create(boolean state, int count) {
        return new ProductStatePair(
                state ? count : 0,
                state ? 0 : count);
    }
}
